<template>
	<div class="p_20 indexBanner">
		<el-dialog :visible.sync="isShow" :close-on-click-modal="false" @close="closeDialog">
			<!-- <el-divider></el-divider> -->
			<el-form :model="form" label-width="80px">
				<el-form-item label="公司名称">
					<el-input v-model="form.company" class="w_400"></el-input>
				</el-form-item>
				<el-form-item label="地区">
					<el-input v-model="form.area" class="w_400"></el-input>
				</el-form-item>
				<el-form-item label="地址">
					<el-input v-model="form.company_address" class="w_400"></el-input>
				</el-form-item>
				<el-form-item label="电话">
					<el-input v-model="form.phone" class="w_400"></el-input>
				</el-form-item>
				<el-form-item label="传真">
					<el-input v-model="form.fox" class="w_400"></el-input>
				</el-form-item>
				<el-form-item label="邮箱">
					<el-input v-model="form.e_mail" class="w_250"></el-input>
					<!-- <span>（数字越大越靠前）</span> -->
				</el-form-item>
				
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="closeDialog">取 消</el-button>
				<el-button type="primary" @click="submit">确 定</el-button>
			</span>
		</el-dialog>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				isShow: false,
				form: {
					id:'',
					company:'',
					area:'',
					company_address:'',
					fox:'',
					phone:'',
					e_mail:''
				},

				//图片上传
				imageUrl: '',
				// dialogVisible: false,
				// disabled: false
			}
		},
		methods: {
			//提交
			submit(){
				
				let params = this.form;
				console.log(params);
				params.language = this.$store.getters.getLanguage;
				if(this.form.id) {
					this.edit(params);
				}else {
					this.add(params);
				}
			},
			
			
			//新增
			add(params){
				this.axiosPost('Contact/contactAdd', params , res => {
					if(res.data.code === 0) {
						this.msgSuccess(res.data.message);
						this.$parent.getTableData();
						this.isShow = false;
					}
				})
			},
			
			//编辑
			edit(params) {
				this.axiosPost('Contact/contactEdit', params , res => {
					if(res.data.code === 0) {
						this.msgSuccess(res.data.message);
						this.$parent.getTableData();
						this.isShow = false;
					}
				})
			},


			
			
			//关闭窗口 清空数据
			closeDialog(){
				this.form = {
					id:'',
					company:'',
					area:'',
					company_address:'',
					fox:'',
					phone:'',
					e_mail:''
				}
				this.imageUrl = ''
				this.isShow = false;
			}
		}
	}
</script>

<style scoped>

</style>
